From news-rocq.inria.fr!jussieu.fr!univ-lyon1.fr!newsfeed.nacamar.de!news.maxwell.syr.edu!news.mel.connect.com.au!munnari.OZ.AU!comp.vuw.ac.nz!paramount.mcs.vuw.ac.nz!amarsden Fri Mar 6 11:34:53 1998 Article: 8511 of rec.games.corewar Path: news-rocq.inria.fr!jussieu.fr!univ-lyon1.fr!newsfeed.nacamar.de!news.maxwell.syr.edu!news.mel.connect.com.au!munnari.OZ.AU!comp.vuw.ac.nz!paramount.mcs.vuw.ac.nz!amarsden From: Anton Marsden Newsgroups: rec.games.corewar Subject: P^2b - another p-switcher Date: Fri, 6 Mar 1998 15:38:07 +1300 Organization: School of Mathematical and Computing Sciences, VUW Lines: 70 Message-ID: Reply-To: Anton Marsden NNTP-Posting-Host: kaukau.mcs.vuw.ac.nz Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Cache-Post-Path: kaukau.mcs.vuw.ac.nz!unknown@paramount.mcs.vuw.ac.nz X-Cache: nntpcache 2.3.2.1 (see http://www.nntpcache.org/) P^2b is based upon the ideas presented in the P^2 switcher. P^2 has a major weakness: it needs a very large table to implement even simple state transitions. Generally, the state transition rules we use for one component can be used with another - but P^2 doesn't take this into account. P^2b attempts to use this transition similarity property. P^2b takes 7 instructions to execute (as opposed to 6 for P^2). In order to keep the code size to a minimum, it is required that state 0 and state 1 execute the same warrior. Apart from this restriction, it should be possible to implement any state transition table that was possible in P^2. However, keep in mind that the initial state is a little bit tricky to set up properly - this is left as an exercise for the reader. I'm not going to describe how P^2b works any further - there are some hints in the code and I don't have much time at the moment. If you don't understand it, figure out how P^2 works first. ;redcode-94 ;name P^2b ;author Anton Marsden ;strategy P-switcher ;assert CORESIZE==8000 PSTATE EQU 666 ; pspace location containing current state STATES EQU 9 ; number of states ;T1, T2 and T3 correspond to different states a component can be in. ;In this case, T2 and T3 use the same win/loss/tie table to switch states. T1 EQU (t1-in) T2 EQU (t2-in) T3 EQU (t2-in) think ldp.a #0,in ; get input value load ldp.a #PSTATE,state ; load old state mod.a #STATES,state ; brainwash protection add.ba *state,in ; select correct state table in add.ba 0,state store stp.a state,load ; store new state state jmp }0,T1 ; jump to warrior code dat w1,T2 ; if state.A == 0, the A field of this ; instruction will be jumped to. dat w1,T3 dat w2,T1 dat w2,T2 dat w2,T3 dat w3,T1 dat w3,T2 dat w3,T3 t2 dat w1,1 ; loss - add 1 to the state dat 0,-1 ; win - subtract 1 from the state dat 0,0 ; tie - leave the state as it is t1 dat 0,1 ; loss - add 1 to the state dat 0,0 ; win - leave the state as it is dat 0,0 ; tie - leave the state as it is ;Warrior code w1: jmp #1,1 w2: jmp #2,2 w3: jmp #3,3 END think